/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ucjava.chat.commserve.rmi.common;

import java.rmi.Remote;
import java.rmi.RemoteException;

/**
 * Stub pointing to RMI Server.
 * 
 * @author tony
 */
public interface IChatService extends Remote
{

    /**
     *
     * Pass: String - username String - password IChatClient - a "stub" the
     * server can refer to to call the client's receiveMessage() method.
     *
     * 
     * Returns a status code: ResultCodes.LOGIN_OK on success, or
     * ResultCodes.NO_SUCH_USER or ResultCodes.ALREADY_LOGGED_IN or
     * ResultCodes.WRONG_PASSWORD
     *
     *Also throws RemoteException if the RMI call fails.
     * 
     *
     * @param username
     * @param password
     * @param rcvMsgStub
     * @return
     * @throws RemoteException
     */
    ResultCodes login(String username, String password,
            IChatClientRMI rcvMsgStub) throws RemoteException;

    /**
     * Returns a status code: ResultCodes.LOGOUT_OK on success, or
     * ResultCodes.NO_SUCH_USER or ResultCodes.NOT_LOGGED_IN
     *
     * Also throws RemoteException if the RMI call fails.
     * 
     * @param username
     * @return
     * @throws RemoteException
     */
    ResultCodes logout(String username) throws RemoteException;

    /**
     * Returns ResultCodes.MSG_SENT_OK on success, or
     * ResultCodes.NOT_LOGGED_IN if username is not logged in.
     * 
     * Also throws RemoteException if the RMI call fails.
     * 
     */
    ResultCodes sendMessage(Message msg, String username) throws RemoteException;

}
